class AppError extends Error {
  constructor(message, status) {
    super(message);
    this.status = status;
  }
}

function catchAsync(fn) {
  return function(req, res, next) {
    Promise.resolve(fn(req, res, next)).catch(next);
  };
}

module.exports = { catchAsync, AppError };
